package com.basker.pisces.core.query;

import com.basker.pisces.core.query.meta.FieldDesc;

public class OrderField {
    public static final String ASC = "ASC";
    public static final String DESC = "DESC";

    private String order = ASC;
    private String fieldId;

    public OrderField() {

    }

    public OrderField(FieldDesc field) {
        this(field.getId(), ASC);
    }

    public OrderField(FieldDesc field, String order) {
        this(field.getId(), order);
    }

    public OrderField(String fieldId, String order) {
        this.fieldId = fieldId;
        this.setOrder(order);
    }

    public String getFieldId() {
        return fieldId;
    }

    public String getOrder() {
        return order;
    }

    public void setFieldId(String fieldId) {
        this.fieldId = fieldId;
    }

    public void setOrder(String order) {
        if (!ASC.equals(order) && !DESC.equals(order)) {
            order = ASC;
        }
        this.order = order;
    }
}